export const phoneReg = /^[0-9]{11}$/;
export const cardReg = /^[1-9]\d{16}(\d|X|x)$/;

// 定义一个函数，用于禁止选择当前时间之前的日期
export const dateDisabled = (current) => {
  const currentDate = new Date();
  // 将当前日期设为午夜
  currentDate.setHours(0, 0, 0, 0);

  return current && current < currentDate;
};

// 定义一个函数，用于禁止选择当前时间之前的日期
export const dateNowDisabled = (current) => {
  const tomorrow = new Date();
  tomorrow.setDate(tomorrow.getDate() + 1);
  tomorrow.setHours(0, 0, 0, 0);

  return current && current >= tomorrow;
};

export const dateNowYearDisabled = (current) => {
  const today = new Date();
  today.setHours(0, 0, 0, 0);

  // 获取明天的日期
  const tomorrow = new Date();
  tomorrow.setDate(tomorrow.getDate() + 1);
  tomorrow.setHours(0, 0, 0, 0);

  // 获取今年的第一天
  const firstDayOfYear = new Date(today.getFullYear(), 0, 1);

  // 允许选择今年的日期，并且日期不能大于明天
  return current && (current < firstDayOfYear || current >= tomorrow);
};
